<%--
  Created by IntelliJ IDEA.
  User: LJS
  Date: 2018/11/14
  Time: 23:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true"%>
<%@page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName()
            + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>公文培训管理</title>
    <jsp:include page="resource.jsp"/>
    <script type="text/javascript">
        //Confirm modal
        function confirm(id){
            bootbox.confirm({
                message: "删除后数据无法恢复",
                title: "确定删除 ?",
                callback: function(result) {
                    //callback result
                    console.log(result);
                    if(result === true){
                        deleteOne(id);
                    }
                }
            });
        }

        //deleteOne
        function deleteOne(id){
            $.ajax({
                url:"${pageContext.request.contextPath}/train/deleteOne.do",
                type:"post",
                async:false,
                data:{staffTrainId:id},
                dataType: 'json',
                success:function(data){
                    if(data.res.trim() === "1" ) {
                        window.location.reload();
                    }else{
                        //...
                    }
                }
            })
        }
    </script>
</head>
<body>
<jsp:include page="common.jsp"/>

<!-- Start #content -->
<div id="content">
    <!-- Start .content-wrapper -->
    <div class="content-wrapper">
        <!-- Start .row -->
        <div class="row">
            <!-- Start .page-header -->
            <div class="col-lg-12 heading">
                <h1 class="page-header"><i class="im-file3"></i> 公文培训管理</h1>
            </div>
            <!-- End .page-header -->
        </div>
        <!-- End .row -->
        <!-- Start .outlet -->
        <div class="outlet">
            <!-- Page start here ( usual with .row ) -->
            <div class="row printable">
                <!-- col-lg-12 start here -->
                <div class="col-lg-12">
                    <!-- Start .panel -->
                    <div class="panel panel-default plain">
                        <div class="panel-heading white-bg"></div>
                        <div class="panel-body">
                            <!-- Start .invoice -->
                            <div class="invoice">
                                <!-- Start .invoice-header -->
                                <div class="invoice-header">
                                    <%--<h3 class="text-center">
                                        培训信息总数：<span class="text-primary">XX条</span>
                                    </h3>
                                    <div class="">
                                        <div class="pull-left col-sm-3 text-center">
                                            申请条数：<span class="text-primary">XX条</span>
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            申请待审条数：<span class="text-info">XX条</span>
                                            <!--<span class="invoice-total-sum">XX条</span>-->
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            申请通过条数：<span class="text-success">XX条</span>
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            申请未通过条数：<span class="text-warning">XX条</span>
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            培训待开始条数：<span class="text-primary">XX条</span>
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            培训进行中条数：<span class="text-info">XX条</span>
                                        </div>
                                        <div class="pull-left col-sm-3 text-center">
                                            培训完成条数：<span class="text-success">XX条</span>
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>--%>
                                    <hr/>
                                    <!-- auth -->
                                    <!--  <form class="form-horizontal" role="form" action="basePath.train/person/search.do" method="post"> -->
                                    <form class="form-horizontal" role="form" action="<%=basePath%>train/all/search.do" method="post">
                                        <div class="form-group col-md-6">
                                            <label for="staffNo" class="col-md-4 control-label">员工工号：</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control limitInput" maxlength="20" id="staffNo" name="staffNo">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffName" class="col-md-4 control-label">员工姓名：</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control limitInput" maxlength="20" id="staffName" name="staffName" />
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffTrainStartDate" class="col-md-4 control-label">开始日期：</label>
                                            <div class="col-md-8">
                                                <div class="input-group">
                                                    <input class="form-control datetime-picker2" type="text" id="staffTrainStartDate" name="staffTrainStartDate">
                                                    <span class="input-group-addon"><i class="im-calendar"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffTrainEndDate" class="col-md-4 control-label">结束日期：</label>
                                            <div class="col-md-8">
                                                <div class="input-group">
                                                    <input class="form-control datetime-picker2" type="text" id="staffTrainEndDate" name="staffTrainEndDate">
                                                    <span class="input-group-addon"><i class="im-calendar"></i></span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffTrainUnit" class="col-md-4 control-label">培训单位：</label>
                                            <div class="col-md-8">
                                                <input type="text" class="form-control limitInput" maxlength="20" id="staffTrainUnit" name="staffTrainUnit" />
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffTrainApplyResult" class="col-md-4 control-label">申请结果：</label>
                                            <div class="col-md-8">
                                                <select class="form-control" id="staffTrainApplyResult" name="staffTrainApplyResult">
                                                    <option value="">--请选择--</option>
                                                    <c:forEach items="${applyResultList}" var="apply">
                                                        <option value="${apply.dictId}">${apply.dictItemName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="staffTrainResult" class="col-md-4 control-label">培训结果：</label>
                                            <div class="col-md-8">
                                                <select class="form-control" id="staffTrainResult" name="staffTrainResult">
                                                    <option value="">--请选择--</option>
                                                    <c:forEach items="${trainResultList}" var="result">
                                                        <option value="${result.dictId}">${result.dictItemName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <input type="submit" class="form-control btn btn-primary" value="搜索" />
                                        </div>
                                    </form>
                                </div>
                                <!-- End .invoice-header -->

                                <!-- Start .invoice-content -->
                                <div class="invoice-content">
                                    <a href="<%=basePath%>train/toAdd.do" class="btn btn-primary mb5">新增</a>
                                    <table class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th>编号</th>
                                            <th>员工工号</th>
                                            <th>员工姓名</th>
                                            <th>开始日期</th>
                                            <th>结束日期</th>
                                            <th>培训单位</th>
                                            <th>申请结果</th>
                                            <th>培训结果</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <c:forEach items="${staffTrainList}" var="train">
                                        <tr>
                                            <td>${train.staffTrainId}</td>
                                            <td>${train.staffNo}</td>
                                            <td><a href="#">${train.staffName}</a></td>
                                            <td>
                                                <fmt:formatDate value="${train.staffTrainStartDate}" pattern="yyyy-MM-dd"/>
                                            </td>
                                            <td>
                                                <fmt:formatDate value="${train.staffTrainEndDate}" pattern="yyyy-MM-dd"/>
                                            </td>
                                            <td>${train.staffTrainUnit}</td>
                                            <td>${train.applyResultDict.dictItemName}</td>
                                            <td>${train.trainResultDict.dictItemName}</td>
                                            <td>
                                                <a href="<%=basePath%>train/toEdit.do?staffTrainId=${train.staffTrainId}" class="btn btn-info btn-xs">详情</a>
                                                <button class="btn btn-danger btn-xs" onclick="confirm(${train.staffTrainId})">删除</button>
                                            </td>
                                        </tr>
                                        </c:forEach>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <!-- End .invoice -->
                        </div>
                    </div>
                    <!-- End .panel -->
                </div>
                <!-- col-lg-12 end here -->
            </div>
            <!-- Page End here -->
        </div>
        <!-- End .outlet -->
    </div>
    <!-- End .content-wrapper -->
    <div class="clearfix"></div>
</div>
<!-- End #content -->
</body>
</html>
